package com.ruoyi.stock.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock.domain.QwAbnormalaction;
import com.ruoyi.stock.service.IQwAbnormalactionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 异动记录Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/stock/abnormalaction")
public class QwAbnormalactionController extends BaseController
{
    @Autowired
    private IQwAbnormalactionService qwAbnormalactionService;

    /**
     * 查询异动记录列表
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwAbnormalaction qwAbnormalaction)
    {
        startPage();
        List<QwAbnormalaction> list = qwAbnormalactionService.selectQwAbnormalactionList(qwAbnormalaction);
        return getDataTable(list);
    }

    /**
     * 导出异动记录列表
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:export')")
    @Log(title = "异动记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QwAbnormalaction qwAbnormalaction)
    {
        List<QwAbnormalaction> list = qwAbnormalactionService.selectQwAbnormalactionList(qwAbnormalaction);
        ExcelUtil<QwAbnormalaction> util = new ExcelUtil<QwAbnormalaction>(QwAbnormalaction.class);
        util.exportExcel(response, list, "异动记录数据");
    }

    /**
     * 获取异动记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:query')")
    @GetMapping(value = "/{abnormalactionId}")
    public AjaxResult getInfo(@PathVariable("abnormalactionId") Long abnormalactionId)
    {
        return success(qwAbnormalactionService.selectQwAbnormalactionByAbnormalactionId(abnormalactionId));
    }

    /**
     * 新增异动记录
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:add')")
    @Log(title = "异动记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwAbnormalaction qwAbnormalaction)
    {
        return toAjax(qwAbnormalactionService.insertQwAbnormalaction(qwAbnormalaction));
    }

    /**
     * 修改异动记录
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:edit')")
    @Log(title = "异动记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwAbnormalaction qwAbnormalaction)
    {
        return toAjax(qwAbnormalactionService.updateQwAbnormalaction(qwAbnormalaction));
    }

    /**
     * 删除异动记录
     */
    @PreAuthorize("@ss.hasPermi('stock:abnormalaction:remove')")
    @Log(title = "异动记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{abnormalactionIds}")
    public AjaxResult remove(@PathVariable Long[] abnormalactionIds)
    {
        return toAjax(qwAbnormalactionService.deleteQwAbnormalactionByAbnormalactionIds(abnormalactionIds));
    }
}
